package pl.edu.agh.mr.nb.server;

import java.util.ArrayList;

import sun.misc.Cleaner;

public class ClientArray {

	private ArrayList<Client> clientList;
	
	// client array constructor 
	public ClientArray() {
		clientList = new ArrayList<Client>();
	}

	public void registerClient(Client client) {
		System.out.println(client.clientName+" registered");
		
		clientList.add(client);		
	}

	public Client getClientByName(String clientName) {
		
			for (int i=0; i<clientList.size();i++)
				if (clientList.get(i).clientName.equals(clientName)){
					clientList.get(i).clientStatus = ClientStatus.IDLE;
					return clientList.get(i);
				}
			
		return null;
	}

	public void unregisterClient(String clientName) {

		System.out.println(clientName+" unregistered");
		for (int i=0; i<clientList.size();i++)
			if (clientList.get(i).clientName.equals(clientName)){
				clientList.remove(i);
				return;
			}
	}
	
}
